package com.ternnetwork.core.entity.org;

import java.util.Date;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import com.ternnetwork.core.entity.User;

@Cache(usage =CacheConcurrencyStrategy.READ_WRITE)
@Entity
@Table(name="VS_ORG_USER_RELATIONSHIP")
public class OrganizationUserRelationship {
	
	@EmbeddedId
	@AttributeOverrides( {
	@AttributeOverride(name="userId", column=@Column(name="USER_ID", nullable=false) ), 
	@AttributeOverride(name="organizationId", column=@Column(name="ORG_ID", nullable=false) ) } )
	private OrganizationUserRelationshipId id;
	
    @ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="USER_ID", nullable=false, insertable=false, updatable=false)
	private User user;
	
    @ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name="ORG_ID", nullable=false, insertable=false, updatable=false)
	private Organization organization;
	
	
	@Temporal(TemporalType.TIMESTAMP)@Column(nullable=false,name="CREATE_TIME")
	private Date createTime=new Date();
	
	
	@Temporal(TemporalType.TIMESTAMP)@Column(nullable=false,name="UPDATE_TIME")
	private Date updateTime=new Date();


	public OrganizationUserRelationshipId getId() {
		return id;
	}


	public void setId(OrganizationUserRelationshipId id) {
		this.id = id;
	}


	public User getUser() {
		return user;
	}


	public void setUser(User user) {
		this.user = user;
	}


	public Organization getOrganization() {
		return organization;
	}


	public void setOrganization(Organization organization) {
		this.organization = organization;
	}


	public Date getCreateTime() {
		return createTime;
	}


	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}


	public Date getUpdateTime() {
		return updateTime;
	}


	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	

}
